package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Foo f1=new Foo();
        Foo f2=new Foo();
        new Thread(()->f1.doSome()).start();
        new Thread(()->f2.doSome()).start();
        new Thread(Foo::doSome).start();

    }
}
class Foo{
    public static void doSome(){
        synchronized (Foo.class) {
            try {
                Thread t=Thread.currentThread();
                System.out.println(t.getName()+"正在执行print方法");
                Thread.sleep(2000);
                System.out.println(t.getName()+"执行完毕");
            } catch (InterruptedException e) {

            }
        }
    }
}
